<html>
<head><meta charset="utf-8"><title>Contributing to the standard library · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Contributing.20to.20the.20standard.20library.html">Contributing to the standard library</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="224973361"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Contributing%20to%20the%20standard%20library/near/224973361" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Gowri <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Contributing.20to.20the.20standard.20library.html#224973361">(Feb 03 2021 at 04:51)</a>:</h4>
<p>hi team,</p>
<p>if i were to say, add a method to a collection in the standard library, how might i try to build it and use it in a local environment? this is my first time getting my hands dirty with contributing. i read the somewhat extensive dev guide, yet still unclear on this. i currently have ran <code>./x.py build -i library/alloc</code>to just build that specific part and have created a toolchain.</p>
<p>however, i cannot use one of the new methods that i just created, any help is welcome</p>
<p>thanks</p>



<a name="224978589"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Contributing%20to%20the%20standard%20library/near/224978589" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Contributing.20to.20the.20standard.20library.html#224978589">(Feb 03 2021 at 06:28)</a>:</h4>
<p><span class="user-mention" data-user-id="386574">@Gowri</span> I don't think you can use x.py to test changes to libstd without building a stage1 compiler. You can do that with <code>x.py build --stage 1 library/std</code>.</p>



<a name="224989463"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Contributing%20to%20the%20standard%20library/near/224989463" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> XAMPPRocky <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Contributing.20to.20the.20standard.20library.html#224989463">(Feb 03 2021 at 09:06)</a>:</h4>
<p>FWIW as someone who has also been working on more on libstd, needing <code>--stage 1</code> for <code>build</code> was pretty unintuitive for me, I would expect build to build the source code I have.</p>



<a name="225019465"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Contributing%20to%20the%20standard%20library/near/225019465" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Contributing.20to.20the.20standard.20library.html#225019465">(Feb 03 2021 at 14:07)</a>:</h4>
<p><span class="user-mention" data-user-id="219696">@XAMPPRocky</span> needing to build <em>against</em> libstd seems kind of rare - if you just want to build your own changes you can use <code>build --stage 0 library/std</code></p>



<a name="225019887"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Contributing%20to%20the%20standard%20library/near/225019887" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> XAMPPRocky <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Contributing.20to.20the.20standard.20library.html#225019887">(Feb 03 2021 at 14:10)</a>:</h4>
<p><span class="user-mention" data-user-id="232545">@Joshua Nelson</span> Well maybe this situation is rare, but what I'm working is adding support for a platform not currently available to Rust, so I have to build a stage 1 compiler that has the target information and then build libstd with that compiler that has that target information.</p>



<a name="225020090"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Contributing%20to%20the%20standard%20library/near/225020090" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Contributing.20to.20the.20standard.20library.html#225020090">(Feb 03 2021 at 14:11)</a>:</h4>
<p>Oh I see. I don't know if there's a way around that, the bootstrap compiler doesn't know about your target</p>



<a name="225020289"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Contributing%20to%20the%20standard%20library/near/225020289" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Contributing.20to.20the.20standard.20library.html#225020289">(Feb 03 2021 at 14:12)</a>:</h4>
<p>It's rarer than contributing to libstd alone, so it isn't the default</p>



<a name="225020785"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Contributing%20to%20the%20standard%20library/near/225020785" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Contributing.20to.20the.20standard.20library.html#225020785">(Feb 03 2021 at 14:16)</a>:</h4>
<p><span class="user-mention" data-user-id="211727">@Jonas Schievink</span> no, --stage 1 is the default if you say <code>build library/std</code>. That only changes if you run <code>x.py setup library</code> or some similar change to config.toml</p>



<a name="225020832"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Contributing%20to%20the%20standard%20library/near/225020832" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Contributing.20to.20the.20standard.20library.html#225020832">(Feb 03 2021 at 14:16)</a>:</h4>
<p>oh, I see</p>



<a name="225021612"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Contributing%20to%20the%20standard%20library/near/225021612" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Contributing.20to.20the.20standard.20library.html#225021612">(Feb 03 2021 at 14:22)</a>:</h4>
<p>FWIW I do think it would be nice to have a way to link to stage0 std - I think it might be simple as using stage0-sysroot with <code>rustup toolchain link</code>? But I haven't tried</p>



<a name="225021871"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Contributing%20to%20the%20standard%20library/near/225021871" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Contributing.20to.20the.20standard.20library.html#225021871">(Feb 03 2021 at 14:24)</a>:</h4>
<p><span class="user-mention" data-user-id="386574">@Gowri</span> the easy and tested way to do this is to add a unit test</p>



<a name="225021893"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Contributing%20to%20the%20standard%20library/near/225021893" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Contributing.20to.20the.20standard.20library.html#225021893">(Feb 03 2021 at 14:24)</a>:</h4>
<p>Or a doc test</p>



<a name="225094169"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Contributing%20to%20the%20standard%20library/near/225094169" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Gowri <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Contributing.20to.20the.20standard.20library.html#225094169">(Feb 03 2021 at 22:40)</a>:</h4>
<p><span class="user-mention" data-user-id="232545">@Joshua Nelson</span>, Thank you! that was what I was looking for.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>